/**
 * Copyright (C), 2011-2016
 * File Name: InitializeContextListener.java
 * Encoding: UTF-8
 * Date: Feb 29, 2012
 * History: 
 */
package com.waynewan.qcomet.servlet;

import java.net.MalformedURLException;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PropertyConfigurator;

/**
 * 
 * @author WayneWan (bestirwiny@gmail.com)
 * @Date Feb 29, 2012 8:28:23 PM
 */
public class InitializeContextListener implements ServletContextListener {

	/* (non-Javadoc)
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
	 */
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
	}

	/* (non-Javadoc)
	 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
	 */
	@Override
	public void contextInitialized(ServletContextEvent context) {
		String fileName = context.getServletContext().getInitParameter("logConfigurationFile");
		try {
			PropertyConfigurator.configure(context.getServletContext().getResource(fileName));
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}

}
